WPS Office.apk(点击下载) / c.java


package com.kingsoft.iciba.sdk2;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import android.text.TextUtils;
import android.util.Log;
import cn.wps.moffice.common.infoflow.internal.cards.thirdpartyad.ThirdPartyAdParams;
import com.appsflyer.share.Constants;
import com.baidu.tts.loopj.AsyncHttpResponseHandler;
import com.kingsoft.iciba.sdk2.interfaces.IKSCibaQueryResult;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.NetworkInterface;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.UUID;
import java.util.Vector;
import java.util.regex.Pattern;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Marker;

public class c {
    private static c o;
    private Context e;
    private long f;
    private boolean p = true;
    private Vector q;
    private g r;

    private c(Context context) {
        this.e = context;
        this.q = new Vector();
        this.r = new g(this);
        this.r.start();
    }

    public static c a(Context context, long j) {
        if (o == null) {
            o = new c(context);
        }
        o.e = context;
        o.f = j;
        return o;
    }

    private static String a(Context context, String str, String str2) {
        try {
            return context.getSharedPreferences("iciba", 0).getString(str, str2);
        } catch (Exception e2) {
            e2.printStackTrace();
            return str2;
        }
    }

    public static String a(Context context, JSONObject jSONObject, long j) {
        JSONObject jSONObject2 = new JSONObject();
        Long valueOf = Long.valueOf(System.currentTimeMillis() / 1000);
        try {
            jSONObject2.put("protocol", 2);
            jSONObject2.put("userip", e());
            jSONObject2.put("cid", 7);
            jSONObject2.put("time", valueOf);
            jSONObject2.put("uuid", b(context));
            jSONObject2.put("p", Long.toString(j));
            jSONObject2.put("package_name", c(context));
            jSONObject2.put("sign", f(b(context) + 7 + valueOf + "icibaclient_#&$%"));
            jSONObject2.put("g", (context instanceof Activity ? ((Activity) context).getWindowManager().getDefaultDisplay().getWidth() : 0) + Marker.ANY_MARKER + (context instanceof Activity ? ((Activity) context).getWindowManager().getDefaultDisplay().getHeight() : 0));
            jSONObject2.put("n", i.e(context));
            String str = Build.MODEL;
            if (Boolean.valueOf(Pattern.compile("(\\d.*?)").matcher(str).matches()).booleanValue()) {
                str = g("persist.sys.device_name");
            }
            jSONObject2.put("m", str);
            jSONObject2.put("s", Build.VERSION.RELEASE);
            jSONObject2.put("ver", "2.0.4");
            JSONArray jSONArray = new JSONArray();
            jSONArray.put(jSONObject);
            jSONObject2.put("events", jSONArray);
            JSONArray jSONArray2 = new JSONArray();
            if (a(context, "com.youdao.dict")) {
                jSONArray2.put(1);
            }
            if (a(context, "com.kingsoft")) {
                jSONArray2.put(2);
            }
            jSONObject2.put(Constants.URL_CAMPAIGN, jSONArray2);
            jSONObject2.put(ThirdPartyAdParams.ACTION_AD_ERROR, new JSONArray());
            jSONObject2.put("history", new JSONArray());
        } catch (Exception e2) {
            Log.e("KStatistics", "Create data failed", e2);
        }
        return jSONObject2.toString();
    }

    private static String a(f fVar) {
        if (fVar.B == null) {
            try {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put(NotificationCompat.CATEGORY_STATUS, 0);
                JSONObject jSONObject2 = new JSONObject();
                jSONObject.put("message", jSONObject2);
                jSONObject2.put("result_info", "获取释义失败");
                jSONObject2.put("word_name", fVar.x);
                return jSONObject.toString();
            } catch (Exception e2) {
                Log.e("NetSearchManage", "Create Json failed", e2);
                return null;
            }
        } else {
            try {
                JSONObject jSONObject3 = new JSONObject();
                jSONObject3.put(NotificationCompat.CATEGORY_STATUS, 1);
                JSONObject jSONObject4 = new JSONObject();
                jSONObject3.put("message", jSONObject4);
                jSONObject4.put("result_info", "获取释义成功");
                jSONObject4.put("word_name", fVar.x);
                Iterator it = fVar.B.iterator();
                while (it.hasNext()) {
                    AbstractMap.SimpleEntry simpleEntry = (AbstractMap.SimpleEntry) it.next();
                    jSONObject4.put((String) simpleEntry.getKey(), new JSONObject((String) simpleEntry.getValue()));
                }
                return jSONObject3.toString();
            } catch (Exception e3) {
                Log.e("NetSearchManage", "Create Json failed", e3);
                return null;
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:11:0x0017, code lost:
        r1 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:12:0x0018, code lost:
        r1 = r0;
        r0 = r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:24:0x0037, code lost:
        r0 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:25:0x0038, code lost:
        r1 = null;
     */
    public static String a(InputStream inputStream) {
        Exception e2;
        String str;
        ByteArrayOutputStream byteArrayOutputStream;
        Throwable th;
        try {
            byteArrayOutputStream = new ByteArrayOutputStream(16384);
            copyStream(inputStream, byteArrayOutputStream);
            str = byteArrayOutputStream.toString(AsyncHttpResponseHandler.DEFAULT_CHARSET);
            try {
                byteArrayOutputStream.close();
            } catch (Exception e3) {
                e2 = e3;
                Log.e("Utils", "Load string from stream failed", e2);
                return str;
            }
        } catch (Exception e4) {
            e2 = e4;
            str = null;
            Log.e("Utils", "Load string from stream failed", e2);
            return str;
        }
        return str;
        throw th;
        if (th != null) {
            try {
                byteArrayOutputStream.close();
            } catch (Throwable th2) {
                th.addSuppressed(th2);
            }
        } else {
            byteArrayOutputStream.close();
        }
        throw th;
    }

    private String a(JSONObject jSONObject, f fVar) {
        try {
            if (jSONObject.optJSONObject("message") != null) {
                JSONObject jSONObject2 = new JSONObject();
                jSONObject2.put(NotificationCompat.CATEGORY_STATUS, 1);
                JSONObject jSONObject3 = new JSONObject();
                jSONObject2.put("message", jSONObject3);
                jSONObject3.put("word_name", fVar.x);
                jSONObject3.put("result_info", "获取释义成功");
                JSONObject optJSONObject = ((JSONObject) jSONObject.get("message")).optJSONObject("baesInfo");
                if (optJSONObject != null) {
                    jSONObject3.put("baseInfo", a(optJSONObject));
                }
                if (fVar.B != null) {
                    Iterator it = fVar.B.iterator();
                    while (it.hasNext()) {
                        AbstractMap.SimpleEntry simpleEntry = (AbstractMap.SimpleEntry) it.next();
                        jSONObject3.put((String) simpleEntry.getKey(), new JSONObject((String) simpleEntry.getValue()));
                    }
                }
                return jSONObject2.toString();
            }
        } catch (JSONException e2) {
            e2.printStackTrace();
        }
        return null;
    }

    private static JSONObject a(JSONObject jSONObject) {
        int i;
        JSONObject jSONObject2 = new JSONObject();
        try {
            if (!jSONObject.isNull("translate_type")) {
                i = jSONObject.getInt("translate_type");
                jSONObject2.put("translate_type", i);
            } else {
                jSONObject2.put("translate_type", 1);
                i = 1;
            }
            if (i == 1) {
                if (!jSONObject.isNull("exchange")) {
                    JSONObject jSONObject3 = jSONObject.getJSONObject("exchange");
                    JSONObject jSONObject4 = new JSONObject();
                    String[] strArr = a.c;
                    for (String str : strArr) {
                        if (!jSONObject3.isNull(str) && jSONObject3.getJSONArray(str).length() > 0) {
                            jSONObject4.put(str, jSONObject3.getJSONArray(str));
                        }
                    }
                    if (jSONObject4.length() > 0) {
                        jSONObject2.put("exchange", jSONObject4);
                    }
                }
                if (!jSONObject.isNull("symbols")) {
                    JSONArray jSONArray = jSONObject.getJSONArray("symbols");
                    JSONArray jSONArray2 = new JSONArray();
                    for (int i2 = 0; i2 < jSONArray.length(); i2++) {
                        JSONObject jSONObject5 = new JSONObject();
                        JSONObject jSONObject6 = jSONArray.getJSONObject(i2);
                        if (!jSONObject6.isNull("word_symbol")) {
                            jSONObject5.put("word_symbol", jSONObject6.getString("word_symbol"));
                        } else {
                            if (!jSONObject6.isNull("ph_en") && !TextUtils.isEmpty(jSONObject6.getString("ph_en"))) {
                                jSONObject5.put("ph_en", jSONObject6.getString("ph_en"));
                            }
                            if (!jSONObject6.isNull("ph_am") && !TextUtils.isEmpty(jSONObject6.getString("ph_am"))) {
                                jSONObject5.put("ph_am", jSONObject6.getString("ph_am"));
                            }
                            if (!jSONObject6.isNull("ph_other") && !TextUtils.isEmpty(jSONObject6.getString("ph_other"))) {
                                jSONObject5.put("ph_other", jSONObject6.getString("ph_other"));
                            }
                        }
                        if (!jSONObject6.isNull("parts") && jSONObject6.getJSONArray("parts").length() > 0) {
                            jSONObject5.put("parts", jSONObject6.getJSONArray("parts"));
                        }
                        if (jSONObject5.length() > 0) {
                            jSONArray2.put(jSONObject5);
                        }
                    }
                    if (jSONArray2.length() > 0) {
                        jSONObject2.put("symbols", jSONArray2);
                    }
                }
            } else if (i == 2) {
                if (!jSONObject.isNull("translate_result")) {
                    jSONObject2.put("translate_result", jSONObject.getString("translate_result"));
                }
                if (!jSONObject.isNull("translate_msg")) {
                    jSONObject2.put("translate_msg", jSONObject.getString("translate_msg"));
                }
            } else if (i == 3 && !jSONObject.isNull("suggest")) {
                jSONObject2.put("suggest", jSONObject.getJSONArray("suggest"));
            }
        } catch (Exception e2) {
            Log.e("NetSearchManage", "Transform Json failed", e2);
        }
        return jSONObject2;
    }

    public static void a(Context context, String str, long j) {
        File file = new File(str + File.separator + "iciba_statistics");
        if (file.exists() && file.length() > PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE) {
            file.delete();
        } else if (a(context)) {
            new Thread(new h(file, context, j)).start();
        }
    }

    static /* synthetic */ void a(c cVar, String str, f fVar) {
        String str2 = null;
        if (str != null) {
            try {
                str2 = cVar.a(new JSONObject(str), fVar);
            } catch (Exception e2) {
                Log.e("NetSearchManage", "Create search result json failed", e2);
            }
        } else {
            str2 = a(fVar);
        }
        fVar.C.searchResult(str2);
    }

    public static boolean a(Context context) {
        try {
            NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
            if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
                return (!activeNetworkInfo.getTypeName().toUpperCase().equals("MOBILE") || activeNetworkInfo.getExtraInfo() == null) ? true : true;
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        return false;
    }

    public static boolean a(Context context, String str) {
        if (str == null || context == null) {
            return false;
        }
        try {
            context.getPackageManager().getPackageInfo(str, 0);
            return true;
        } catch (PackageManager.NameNotFoundException e2) {
            return false;
        } catch (Exception e3) {
            Log.e("Utils", "Get app installed state failed", e3);
            return false;
        }
    }

    public static String b(Context context) {
        if (!TextUtils.isEmpty(a(context, "uuid", ""))) {
            return a(context, "uuid", "");
        }
        String replaceAll = UUID.randomUUID().toString().trim().replaceAll("-", "");
        try {
            SharedPreferences.Editor edit = context.getSharedPreferences("iciba", 0).edit();
            edit.putString("uuid", replaceAll);
            edit.commit();
            return replaceAll;
        } catch (Exception e2) {
            e2.printStackTrace();
            return replaceAll;
        }
    }

    public static String c(Context context) {
        try {
            return context.getPackageName();
        } catch (Exception e2) {
            return null;
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:12:0x001d, code lost:
        r1 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:13:0x001e, code lost:
        r1 = r0;
        r0 = r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:21:0x0029, code lost:
        r1 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:22:0x002a, code lost:
        r2 = r0;
        r0 = r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:25:?, code lost:
        r3.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:33:0x004c, code lost:
        r0 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:35:0x0052, code lost:
        r1 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:36:0x0053, code lost:
        r2.addSuppressed(r1);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:37:0x0057, code lost:
        r3.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:38:0x005b, code lost:
        r0 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:39:0x005c, code lost:
        r1 = null;
     */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x002e A[SYNTHETIC, Splitter:B:24:0x002e] */
    /* JADX WARNING: Removed duplicated region for block: B:33:0x004c A[ExcHandler: all (th java.lang.Throwable)] */
    /* JADX WARNING: Removed duplicated region for block: B:37:0x0057  */
    private static void copyStream(InputStream inputStream, OutputStream outputStream) {
        Throwable th;
        Throwable th2 = null;
        byte[] bArr = new byte[4096];
        try {
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
            while (true) {
                int read = bufferedInputStream.read(bArr);
                if (read != -1) {
                    bufferedOutputStream.write(bArr, 0, read);
                } else {
                    bufferedOutputStream.flush();
                    bufferedOutputStream.close();
                    bufferedInputStream.close();
                    return;
                }
            }
            if (th != null) {
                try {
                    bufferedOutputStream.close();
                } catch (Throwable th3) {
                }
            } else {
                bufferedOutputStream.close();
            }
            throw th;
            throw th;
            throw th;
            if (th2 == null) {
            }
            throw th;
        } catch (IOException e2) {
        } catch (Exception e3) {
            Log.e("Utils", "Copy data failed", e3);
        }
    }

    public static int d(Context context) {
        try {
            return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
        } catch (PackageManager.NameNotFoundException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    static /* synthetic */ HttpClient d() {
        BasicHttpParams basicHttpParams = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(basicHttpParams, 1000);
        HttpConnectionParams.setSoTimeout(basicHttpParams, 10000);
        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme(com.mopub.common.Constants.HTTP, PlainSocketFactory.getSocketFactory(), 80));
        schemeRegistry.register(new Scheme(com.mopub.common.Constants.HTTPS, SSLSocketFactory.getSocketFactory(), 443));
        return new DefaultHttpClient(new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry), basicHttpParams);
    }

    private HttpPost d(String str) {
        try {
            String encode = URLEncoder.encode(str, AsyncHttpResponseHandler.DEFAULT_CHARSET);
            StringBuffer stringBuffer = new StringBuffer();
            stringBuffer.append("http://dict-mobile.iciba.com/interface/index.php");
            stringBuffer.append("?c=word");
            stringBuffer.append("&list=");
            stringBuffer.append("1");
            stringBuffer.append("&client=");
            stringBuffer.append(1);
            String valueOf = String.valueOf(System.currentTimeMillis() / 1000);
            stringBuffer.append("&timestamp=");
            stringBuffer.append(valueOf);
            stringBuffer.append("&sign=");
            stringBuffer.append(f("word" + "#ICIBA!(*&R$@#LOVE#" + "1" + valueOf).substring(5, 21));
            stringBuffer.append("&uuid=");
            stringBuffer.append(b(this.e));
            stringBuffer.append("&sv=");
            stringBuffer.append("android" + Build.VERSION.RELEASE);
            stringBuffer.append("&v=");
            stringBuffer.append("2.0.4");
            stringBuffer.append("&uid=");
            stringBuffer.append("&tc=");
            stringBuffer.append(o.f);
            HttpPost httpPost = new HttpPost(stringBuffer.toString());
            ArrayList arrayList = new ArrayList();
            arrayList.add(new BasicNameValuePair("word", encode));
            try {
                httpPost.setEntity(new UrlEncodedFormEntity(arrayList, AsyncHttpResponseHandler.DEFAULT_CHARSET));
                return httpPost;
            } catch (UnsupportedEncodingException e2) {
                e2.printStackTrace();
                return httpPost;
            }
        } catch (Exception e3) {
            return null;
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:10:0x002c, code lost:
        if (r0.isLoopbackAddress() != false) goto L_0x001c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:12:0x0032, code lost:
        if (r0.isLinkLocalAddress() != false) goto L_0x001c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:14:0x0038, code lost:
        if (r0.isSiteLocalAddress() == false) goto L_0x001c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:15:0x003a, code lost:
        r2.add(r0.getHostAddress().toString());
     */
    /* JADX WARNING: Code restructure failed: missing block: B:20:0x0057, code lost:
        if (r2.size() != 1) goto L_0x0061;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x0066, code lost:
        if (r2.size() < 2) goto L_0x0092;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:24:0x0068, code lost:
        r3 = r2.iterator();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:26:0x0070, code lost:
        if (r3.hasNext() == false) goto L_0x0081;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:27:0x0072, code lost:
        r0 = (java.lang.String) r3.next();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:28:0x007e, code lost:
        if (r0.startsWith("192") == false) goto L_0x006c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:29:0x0080, code lost:
        r1 = r0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:30:0x0081, code lost:
        if (r1 != null) goto L_0x0090;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:34:0x008b, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:35:0x008c, code lost:
        r0 = r1;
        r1 = r0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:3:0x000a, code lost:
        if (r3 != null) goto L_0x000c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:48:?, code lost:
        return (java.lang.String) r2.get(0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:49:?, code lost:
        return r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:50:?, code lost:
        return null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:51:?, code lost:
        return (java.lang.String) r2.get(0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:5:0x0010, code lost:
        if (r3.hasMoreElements() == false) goto L_0x0052;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:6:0x0012, code lost:
        r4 = r3.nextElement().getInetAddresses();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:8:0x0020, code lost:
        if (r4.hasMoreElements() == false) goto L_0x000c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:9:0x0022, code lost:
        r0 = r4.nextElement();
     */
    public static String e() {
        String str = null;
        ArrayList arrayList = new ArrayList();
        try {
            Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
        } catch (Exception e2) {
            String str2 = null;
            Exception exc = e2;
            Log.e("Utils", "Get device ip failed", exc);
            return str2;
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:58:0x00f1, code lost:
        r1 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:59:0x00f2, code lost:
        r2 = r0;
        r0 = r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:69:0x010c, code lost:
        r0 = th;
     */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x005a  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0069  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00ac A[SYNTHETIC, Splitter:B:38:0x00ac] */
    /* JADX WARNING: Removed duplicated region for block: B:47:0x00be  */
    /* JADX WARNING: Removed duplicated region for block: B:51:0x00d3  */
    /* JADX WARNING: Removed duplicated region for block: B:52:0x00da  */
    public static void e(String str) {
        HashMap hashMap;
        HashMap hashMap2;
        JSONObject jSONObject;
        HashMap hashMap3;
        Throwable th;
        HashMap hashMap4;
        Throwable th2;
        Throwable th3 = null;
        File file = new File(a.b + File.separator + "iciba_statistics");
        try {
            if (!file.exists() || file.length() <= 0) {
                hashMap = new HashMap();
            } else {
                try {
                    ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(file));
                    try {
                        HashMap hashMap5 = (HashMap) objectInputStream.readObject();
                        if (hashMap5 != null) {
                            try {
                                if (hashMap5.size() != 0) {
                                    hashMap3 = hashMap5;
                                    objectInputStream.close();
                                    hashMap = hashMap3;
                                }
                            } catch (Throwable th4) {
                                th = th4;
                                th = null;
                                if (th == null) {
                                    try {
                                        objectInputStream.close();
                                    } catch (Throwable th5) {
                                        th.addSuppressed(th5);
                                    }
                                } else {
                                    objectInputStream.close();
                                }
                                throw th;
                            }
                        }
                        hashMap3 = new HashMap();
                        try {
                            objectInputStream.close();
                            hashMap = hashMap3;
                        } catch (Exception e2) {
                            try {
                                file.delete();
                                file.createNewFile();
                                hashMap = hashMap3;
                            } catch (IOException e3) {
                                Log.e("KStatistics", "Create or delete file failed", e3);
                                hashMap = hashMap3;
                            }
                            if (hashMap.containsKey("click_event")) {
                            }
                            if (hashMap2.containsKey(str)) {
                            }
                            hashMap2.put(str, jSONObject.toString());
                            hashMap.put("click_event", hashMap2);
                            ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(file));
                            objectOutputStream.writeObject(hashMap);
                            objectOutputStream.flush();
                            objectOutputStream.close();
                            return;
                        }
                    } catch (Throwable th6) {
                        th = th6;
                        th = null;
                        if (th == null) {
                        }
                        throw th;
                    }
                } catch (Exception e4) {
                    hashMap3 = null;
                    file.delete();
                    file.createNewFile();
                    hashMap = hashMap3;
                    if (hashMap.containsKey("click_event")) {
                    }
                    if (hashMap2.containsKey(str)) {
                    }
                    hashMap2.put(str, jSONObject.toString());
                    hashMap.put("click_event", hashMap2);
                    ObjectOutputStream objectOutputStream2 = new ObjectOutputStream(new FileOutputStream(file));
                    objectOutputStream2.writeObject(hashMap);
                    objectOutputStream2.flush();
                    objectOutputStream2.close();
                    return;
                }
            }
            hashMap2 = hashMap.containsKey("click_event") ? (HashMap) hashMap.get("click_event") : new HashMap();
            if (hashMap2.containsKey(str)) {
                JSONObject jSONObject2 = new JSONObject((String) hashMap2.get(str));
                jSONObject2.put("click_number", jSONObject2.getInt("click_number") + 1);
                jSONObject = jSONObject2;
            } else {
                jSONObject = new JSONObject();
                jSONObject.put("click_number", 1);
            }
            hashMap2.put(str, jSONObject.toString());
            hashMap.put("click_event", hashMap2);
            try {
                ObjectOutputStream objectOutputStream22 = new ObjectOutputStream(new FileOutputStream(file));
                objectOutputStream22.writeObject(hashMap);
                objectOutputStream22.flush();
                objectOutputStream22.close();
                return;
                if (th3 != null) {
                    try {
                        objectOutputStream22.close();
                    } catch (Throwable th7) {
                        th3.addSuppressed(th7);
                    }
                } else {
                    objectOutputStream22.close();
                }
                throw th;
                throw th;
            } catch (Exception e5) {
                Log.e("KStatistics", "Write file failed", e5);
            }
        } catch (Exception e6) {
            Log.e("KStatistics", "Add click event failed", e6);
        }
    }

    public static String f(String str) {
        byte[] bArr;
        try {
            bArr = MessageDigest.getInstance("MD5").digest(str.getBytes(AsyncHttpResponseHandler.DEFAULT_CHARSET));
        } catch (NoSuchAlgorithmException e2) {
            Log.e("Utils", "Calculate md5 failed", e2);
            bArr = null;
        } catch (UnsupportedEncodingException e3) {
            Log.e("Utils", "Calculate md5 failed", e3);
            bArr = null;
        }
        if (bArr == null) {
            return null;
        }
        StringBuilder sb = new StringBuilder(bArr.length << 1);
        for (byte b : bArr) {
            if ((b & 255) < 16) {
                sb.append("0");
            }
            sb.append(Integer.toHexString(b & 255));
        }
        return sb.toString();
    }

    private static String g(String str) {
        try {
            Class<?> cls = Class.forName("android.os.SystemProperties");
            Object invoke = cls.getMethod("get", String.class).invoke(cls, str);
            return invoke == null ? "" : invoke.toString();
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public final void a(String str, IKSCibaQueryResult iKSCibaQueryResult) {
        new Thread(new d(this, str, d(str), iKSCibaQueryResult)).start();
    }

    public final void a(String str, ArrayList arrayList, IKSCibaQueryResult iKSCibaQueryResult) {
        new Thread(new e(this, str, d(str), arrayList, iKSCibaQueryResult)).start();
    }
}